#include <string.h>
#include <iostream>
using std::cout;
using std::endl;

class Computer
{
public:
    void setBrand(const char * brand);//设置品牌
    void setPrice(double price);//设置价格
    void print();//打印信息
private:
    char _brand[20];
    double _price;
};

void Computer::setBrand(const char * brand){
    strcpy(_brand,brand);
}

void Computer::setPrice(double price){
    _price = price;
}

void Computer::print(){
    cout << "brand:" << _brand << endl;
    cout << "price:" << _price << endl;
}

void test0(){
    int num;
    Computer pc;
    //不能用普通函数的调用形式
    /* setBrand("Lenovo"); */

    //成员函数需要通过对象进行调用
    pc.setBrand("Apple");
    pc.setPrice(20000);
    pc.print();

    /* pc._price = 1; */
    /* cout << pc._brand << endl; */
    /* cout << pc._price << endl; */

}

int main(void){
    test0();
    return 0;
}
